import {parseHTML} from './parseAST'
import {generate} from "./generate";


export function compileToFunction(el) {

    // 1.把HTML解析成ast语法树
    let ast = parseHTML(el)
    console.log('ast:', ast)

    // 2. ast语法树转成render字符串
    let code = generate(ast) // _c_v_s
    console.log('code:', code)

    // 3。将render字符串变成函数
    let render = new Function(`with(this){return ${code}}`)
   console.log('render:', render)

    return render


}

/*
let objs = {a:1,b:2}
with(objs){
    console.log(a,b)
}
*/

